package cn.edu.hbwe.book.admin.servlet.books;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.hbwe.book.admin.service.books.BooksService;
import cn.edu.hbwe.book.entity.Book;

/**
 * Servlet implementation class BookListServlet
 */
public class BookListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BooksService service = new BooksService();
		List<Book> lb = service.listAll();
		//将商品信息保存到域对象
		request.setAttribute("lb", lb);
		
		request.getRequestDispatcher("/admin/books/list.jsp").forward(request, response);;
	}

}
